﻿@{
    Layout = null;
}

@model BOSS.Framework.Search.Result.ISearchResult

@using BOSS.Domain.Products
@using BOSS.Web.Extensions

@{
    var data = new
    {
        totalCount = Model.TotalCount,
        rows = Model.UnderlayerItems.OfType<Product>().Select(x => new
        {
            Id = x.Id,
            Url = Url.Action("Details", "Product", new { id = x.Id }),
            Name = x.Name,
            Model = x.Model,
            Specification = x.Specification ?? "",
            Marketable = x.Marketable ? "是" : "否",
            UseCount = x.UseCount.GetValueOrDefault(),
            ProcurementPrice = x.ProcurementPrice,
            SellingPrice = x.SellingPrice,
            Creator = new
            {
                Id = x.Creator == null ? 0 : x.Creator.Id,
                Name = x.Creator == null ? "" : x.Creator.FullName
            },
            CreateTime = Html.EncodeDateTime(x.CreateTime),
            Updator = new
            {
                Id = x.Updator == null ? 0 : x.Updator.Id,
                Name = x.Updator == null ? "" : x.Updator.FullName
            },
            UpdateTime = Html.EncodeDateTime(x.UpdateTime)
        })
    };
    
}

@Html.ToJson(data)
